package com.travel.controller;

import com.qianfeng.util.ResultMsg;
import com.travel.entity.TbHotel;
import com.travel.service.HotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@RestController
@RequestMapping("/adminHotel")
public class AdminHotelController {
    @Autowired
    HotelService hotelService;

    /**
     * 插入新酒店信息
     */
    @PostMapping("/insertHotel")
    public ResultMsg adminInsertHotel(@RequestBody TbHotel hotel){
        return hotelService.adminInsertHotel(hotel);
    }

    /**
     * 查找所有酒店
     * */
    @GetMapping("/getAll")
    public ResultMsg getAll(){
        return hotelService.getAll();
    }

    /**
     * 查找一个酒店
     * */
    @GetMapping("/getOne")
    public ResultMsg getOne(Integer hotelId){
        return hotelService.getOne(hotelId);
    }

    /**
     * 查找所有酒店(分页)
     * */
    @GetMapping("/getAllPage")
    public ResultMsg getAllPage(Integer current,Integer size){
        return hotelService.getAllPage(current,size);
    }

    /**
     * 修改酒店信息
     * */
    @PostMapping("/updateHotel")
    public ResultMsg adminUpdateHotel(@RequestBody TbHotel hotel){
        return hotelService.adminUpdateHotel(hotel);
    }

    /**
     * 删除酒店信息
     * */
    @GetMapping("/deleteHotel")
    public ResultMsg adminDeleteHotel(Integer hotelId){
        return hotelService.adminDeleteHotel(hotelId);
    }

    /**
     * 图片上传
     * */
    @PostMapping("/uploadPic")
    public ResultMsg uploadPic(@RequestBody MultipartFile file){
        return hotelService.uploadPic(file);
    }

}
